﻿//  This file is part of NHibernate.ReLinq.Sample a sample showing
//  the use of the open source re-linq library to implement a non-trivial 
//  Linq-provider, on the example of NHibernate (www.nhibernate.org).
//  Copyright (C) 2005-2009 rubicon informationstechnologie gmbh, www.rubicon.eu
//  
//  NHibernate.ReLinq.Sample is based on re-motion re-linq (http://www.re-motion.org/).
//  
//  NHibernate.ReLinq.Sample is free software; you can redistribute it 
//  and/or modify it under the terms of the MIT License 
// (http://www.opensource.org/licenses/mit-license.php).
// 
using System;
using Remotion.Collections;

namespace NHibernate.ReLinq.Sample.UnitTests.DomainObjects
{
    public class PhoneNumber
    {
        public virtual Guid NHibernateId { get; protected set; }
        public virtual string CountryCode { get; set; }
        public virtual string AreaCode { get; set; }
        public virtual string Number { get; set; }
        public virtual string Extension { get; set; }
        public virtual Person Person { get; set; }


        public static PhoneNumber NewObject()
        {
            return new PhoneNumber();
        }

        public static PhoneNumber NewObject(string CountryCode, string AreaCode, string Number, string Extension, Person person)
        {
            var phoneNumber = NewObject();
            phoneNumber.CountryCode = CountryCode;
            phoneNumber.AreaCode = AreaCode;
            phoneNumber.Number = Number;
            phoneNumber.Extension = Extension;

            if (person != null)
            {
                person.AddPhoneNumber(phoneNumber);
            }

            return phoneNumber;
        }


        public virtual void SetPerson(Person person)
        {
            if (Person != null)
            {
                Person.RemovePhoneNumber(this);
            }
            Person = person;
        }
    }
}